package com.linkwedo.saas.project;

import java.sql.Timestamp;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.util.DateUtil;
import com.opensymphony.xwork2.ActionSupport;


public class DeleteProjectAction extends ActionSupport implements ServletRequestAware{
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	private static final long serialVersionUID = 8190003683775267839L;
	private ProjectService projectService;
	public ProjectService getProjectService() {
		return projectService;
	}

	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}
	private Integer pid;

	private javax.servlet.http.HttpServletRequest request;
	public void setServletRequest(HttpServletRequest request) {
		// TODO Auto-generated method stub
		this.request=request;
	}
	
	private List<Project> list;
	public List<Project> getList() {
		return list;
	}

	public void setList(List<Project> list) {
		this.list = list;
	}	
	public String execute() throws Exception {
		String idStr=request.getParameter("pid");
		if(null == idStr || idStr.equalsIgnoreCase("")){
			return ERROR;
		}
		pid = Integer.parseInt(idStr);
		//getProjectService().deleteById(pid);//.disableById(pid)
		getProjectService().disableById(pid);
		list=getProjectService().findAll();
		return "ok";
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}
	
	}
